Skip to content

Fix poll functions on sockets not properly registering the waker. - #2535

Merged
davidv1992 merged 1 commit into
mainfrom
timestamped-socket-poll-waker
Oct 21, 2026
Merged

davidv1992 merged 1 commit into
mainfrom
timestamped-socket-poll-waker

Conversation

@davidv1992

Copy link
Copy Markdown
Member

When poll_x_ready returned ready, but the try_io function failed with a wouldblock error, we would return std::task::Poll::Pending without properly registering the waker. Retrying the operation as a whole in that case is a better way to ensure the waker does get registered.

@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 30.00000% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.05%. Comparing base (c732ec4) to head (4660184).

Files with missing lines Patch % Lines
timestamped-socket/src/socket.rs 30.00% 28 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2535      +/-   ##
==========================================
- Coverage   79.06%   79.05%   -0.02%     
==========================================
  Files         132      132              
  Lines       26985    26990       +5     
==========================================
+ Hits        21336    21337       +1     
- Misses       5649     5653       +4     
Flag Coverage Δ
test-aarch64-apple-darwin 80.73% <0.00%> (-0.02%) ⬇️
test-x86_64-unknown-linux-gnu 78.95% <30.00%> (-0.02%) ⬇️
test-x86_64-unknown-linux-musl 79.09% <30.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@davidv1992 davidv1992 linked an issue Oct 15, 2026 that may be closed by this pull request
@squell

squell commented Oct 19, 2026

Copy link
Copy Markdown
Member

How is an infinite loop (which would be hard to troubleshoot, perhaps) avoided in this scenario?

@davidv1992

Copy link
Copy Markdown
Member Author

It is not, we assume the OS behaves somewhat reasonable and doesn't endlessly signal a non-ready socket as ready.

@rnijveld

Copy link
Copy Markdown
Member

I think it's important to realize that try_io catches any WouldBlock error returned from the inner function and then clears the ready flag (in tokio). Meaning that the std::task::Poll::Ready(Ok(_)) branch will only be triggered once something in the OS sets the ready flag within tokio again.

rnijveld
rnijveld previously approved these changes Oct 20, 2026
@squell

squell commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

I would suggest adding the assumption in a comment in the source code. (I agree that it's not a real problem.). Can save debugging if someone else is troubleshooting in this neck of the woods 3 years from now. :-)

When poll_x_ready returned ready, but the try_io function failed with a
wouldblock error, we would return std::task::Poll::Pending without
properly registering the waker. Retrying the operation as a whole in
that case is a better way to ensure the waker does get registered.
@davidv1992

Copy link
Copy Markdown
Member Author

Have added the requested comment, but that means this will need a second review

@davidv1992
davidv1992 requested a review from rnijveld October 21, 2026 08:12
@davidv1992
davidv1992 added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 4666845 Oct 21, 2026
24 checks passed
@davidv1992
davidv1992 deleted the timestamped-socket-poll-waker branch October 21, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail to register waker in poll_recv in timestamped_socket.

3 participants